//
//  ParserTest.swift
//  LoopTests
//
//  Created by thomas on 2020/9/23.
//

import XCTest
@testable import Loop

class ParserTest: XCTestCase {

    override func setUpWithError() throws {
    }

    override func tearDownWithError() throws {
    }

    func testParseSucceed() throws {

        let json = """
            {
              "current_user_url": "https://api.github.com/user",
              "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
              "authorizations_url": "https://api.github.com/authorizations"
            }
        """.data(using: .utf8)

        let dict: [String: String]? = Parser.parse(json: json!)

        XCTAssertNotNil(dict)
    }

    func testParseFailure() throws {

        let json = "any string".data(using: .utf8)
        let dict: [String: String]? = Parser.parse(json: json!)

        XCTAssertNil(dict)
    }
}
